package cn.stylefeng.guns.modular.order.service.impl;

import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
import cn.stylefeng.guns.modular.order.mapper.OrderVerificationCodeMapper;
import cn.stylefeng.guns.modular.order.model.OrderVerificationCode;
import cn.stylefeng.guns.modular.order.service.IOrderVerificationCodeService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Auther: 杨煜
 * @Date: 2019/12/11 13:13
 * @Description:
 */
@Service
public class OrderVerificationCodeServiceImpl extends ServiceImpl<OrderVerificationCodeMapper, OrderVerificationCode> implements IOrderVerificationCodeService {



    @Override
    public Page<Map<String, Object>> selectOrderVerificationCodes(String condition) {
        Page page = LayuiPageFactory.defaultPage();
        return this.baseMapper.selectOrderVerificationCodes(page,condition);

    }

    @Override
    public OrderVerificationCode verifyCode(String code) {
        Map<String, Object> map = new HashMap<>();
        map.put("code",code);
        map.put("status",0);
        List<OrderVerificationCode> list = this.baseMapper.selectByMap(map);
        if(!CollectionUtils.isEmpty(list)){
            return list.get(0);
        }
        return null;
    }
}
